package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotion.AutoClearRedis;
import com.sky.annotion.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface DishMapper {

    /**
     * 根据分类id查询菜品数量
     * @param categoryId
     * @return
     */
    @Select("select count(id) from sky_take_out.dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);

    @AutoFill(OperationType.INSERT)
    @AutoClearRedis
    void insertDish(Dish dish);

    @AutoFill(OperationType.UPDATE)
    @AutoClearRedis
    void updateDish(Dish dish);

    @Select("select * from sky_take_out.dish where id = #{id}")
    Dish get(Long id);

    Page<Dish> QueryDishPage(DishPageQueryDTO dishPageQueryDTO);

    @AutoClearRedis
    void bachDelete(String[] ids);


    List<Dish> list(Dish dish);

    Integer countByMap(Map map);
}
